{layout name="layout" /}

<div class="Hui-article">
    <article class="cl pd-20">
        <form action="" method="post" class="form form-horizontal" id="form-admin-add">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>管理员名称：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" id="username" name="username" value="" placeholder="管理员名称">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>初始密码：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="password" class="input-text" autocomplete="off" id="password" name="password" value="" placeholder="初始密码">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>笔名：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" id="pen_name" name="pen_name" value="" placeholder="笔名">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>邮箱：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" id="email" name="email" value="" placeholder="请输入邮箱" autocomplete='email' />
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">组别：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <span class="select-box" style="width:150px;">
                        <select class="select" id="role_id" name="role_id">
                            {foreach $data_role as $k=>$op}
                            <option value="{$k}">{$op}</option>
                            {/foreach}
                        </select>
                    </span>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">备注：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <textarea id="description" name="description" cols="" rows="" class="textarea" placeholder="备注...200个字符以内" dragonfly="true"
                        onKeyUp="textarealength(this,200)"></textarea>
                    <p class="textarea-numberbar">
                        <em class="textarea-length">0</em>/200</p>
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-success radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    <input class="btn btn-default radius" type="button" value="&nbsp;&nbsp;取消&nbsp;&nbsp;" onClick="window.history.back();">
                </div>
            </div>
        </form>
    </article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $(function () {
        $("#form-admin-add").submit(function () {
            var desc = $("#description").val();
            var email = $("#email").val();

            if (!$("#username").val() || !$("#password") || !$("#role_id").val) {
                layer.msg('用户名 or 密码 or 角色 不能为空!', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }
            
            if (testEmail(email) == false) {
                layer.msg('邮箱格式不正确', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }

            if (getblen(desc) > 200) {
                layer.msg('备注过长', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }
        })
    })
</script>
<!--请在上方写此页面业务相关的脚本-->